package com.tencent.smtt.sdk;

import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Looper;
import android.os.Process;
import android.util.Log;
import androidx.core.os.EnvironmentCompat;
import androidx.core.provider.FontsContractCompat;
import com.tencent.smtt.export.external.DexLoader;
import com.tencent.smtt.export.external.interfaces.IX5WebViewBase;
import com.tencent.smtt.sdk.TbsDownloadConfig;
import com.tencent.smtt.sdk.TbsListener;
import com.tencent.smtt.utils.TbsLog;
import com.tencent.smtt.utils.TbsLogClient;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.ksoap2.transport.ServiceConnection;

/* loaded from: classes.dex */
public class QbSdk {
    private static boolean A = false;
    private static boolean B = true;
    private static TbsListener C = null;
    private static TbsListener D = null;
    private static boolean E = false;
    public static final int EXTENSION_INIT_FAILURE = -99999;
    private static boolean F = false;
    public static final String LOGIN_TYPE_KEY_PARTNER_CALL_POS = "PosID";
    public static final String LOGIN_TYPE_KEY_PARTNER_ID = "ChannelID";
    public static final String PARAM_KEY_FEATUREID = "param_key_featureid";
    public static final String PARAM_KEY_FUNCTIONID = "param_key_functionid";
    public static final String PARAM_KEY_POSITIONID = "param_key_positionid";
    public static final int QBMODE = 2;
    public static final String SVNVERSION = "jnizz";
    public static final int TBSMODE = 1;
    public static final String TID_QQNumber_Prefix = "QQ:";
    public static final int VERSION = 1;
    static boolean b = false;
    static boolean c = true;
    static String d = null;
    static boolean e = false;
    static long f = 0;
    static long g = 0;
    static boolean i = true;
    static boolean j = true;
    static boolean k = false;
    public static boolean mDisableUseHostBackupCore = false;
    private static int o = 0;
    private static String p = "";
    private static Class<?> q = null;
    private static Object r = null;
    private static boolean s = false;
    public static boolean sIsVersionPrinted = false;
    private static String[] t = null;
    private static String u = "NULL";
    private static String v = "UNKNOWN";
    private static int w = 0;
    private static int x = 170;
    private static String y;
    private static String z;
    static Object h = new Object();
    static boolean a = false;
    static volatile boolean l = a;
    static TbsListener m = new n();
    public static String KEY_SET_SENDREQUEST_AND_UPLOAD = "SET_SENDREQUEST_AND_UPLOAD";
    static Map<String, Object> n = null;

    /* loaded from: classes.dex */
    public interface PreInitCallback {
        void onCoreInitFinished();

        void onViewInitFinished(boolean z);
    }

    public static Bundle a(Context context, Bundle bundle) {
        TbsLogReport a2;
        String str;
        if (a(context)) {
            Object a3 = com.tencent.smtt.utils.q.a(r, "incrUpdate", new Class[]{Context.class, Bundle.class}, context, bundle);
            if (a3 != null) {
                return (Bundle) a3;
            }
            a2 = TbsLogReport.a(context);
            str = "incrUpdate return null!";
        } else {
            a2 = TbsLogReport.a(context);
            str = "initForPatch return false!";
        }
        a2.a(TbsListener.ErrorCode.INCR_UPDATE_ERROR, str);
        return null;
    }

    public static Object a(Context context, String str, Bundle bundle) {
        if (a(context)) {
            Object a2 = com.tencent.smtt.utils.q.a(r, "miscCall", new Class[]{String.class, Bundle.class}, str, bundle);
            if (a2 != null) {
                return a2;
            }
            return null;
        }
        return Integer.valueOf((int) EXTENSION_INIT_FAILURE);
    }

    public static String a() {
        return p;
    }

    public static synchronized void a(Context context, String str) {
        synchronized (QbSdk.class) {
            if (a) {
                return;
            }
            a = true;
            v = "forceSysWebViewInner: " + str;
            TbsLog.e("QbSdk", "QbSdk.SysWebViewForcedInner..." + v);
            TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_FORCE_SYSTEM_WEBVIEW_INNER, new Throwable(v));
        }
    }

    static boolean a(Context context) {
        try {
            if (q != null) {
                return true;
            }
            File r2 = am.a().r(context);
            if (r2 == null) {
                TbsLog.e("QbSdk", "QbSdk initExtension (false) optDir == null");
                return false;
            }
            File file = new File(r2, "tbs_sdk_extension_dex.jar");
            if (!file.exists()) {
                TbsLog.e("QbSdk", "QbSdk initExtension (false) dexFile.exists()=false", true);
                return false;
            }
            TbsLog.i("QbSdk", "new DexLoader #3 dexFile is " + file.getAbsolutePath());
            q = new DexLoader(file.getParent(), context, new String[]{file.getAbsolutePath()}, r2.getAbsolutePath(), null).loadClass("com.tencent.tbs.sdk.extension.TbsSDKExtension");
            loadTBSSDKExtension(context, file.getParent());
            return true;
        } catch (Throwable th) {
            TbsLog.e("QbSdk", "initExtension sys WebView: " + Log.getStackTraceString(th));
            return false;
        }
    }

    public static boolean a(Context context, int i2) {
        return a(context, i2, (int) ServiceConnection.DEFAULT_TIMEOUT);
    }

    static boolean a(Context context, int i2, int i3) {
        Map<String, Object> map = n;
        if (map != null && map.containsKey(KEY_SET_SENDREQUEST_AND_UPLOAD) && n.get(KEY_SET_SENDREQUEST_AND_UPLOAD).equals("false")) {
            TbsLog.i("QbSdk", "[QbSdk.isX5Disabled] -- SET_SENDREQUEST_AND_UPLOAD is false");
            return true;
        } else if (c(context)) {
            Object a2 = com.tencent.smtt.utils.q.a(r, "isX5Disabled", new Class[]{Integer.TYPE, Integer.TYPE, Integer.TYPE}, Integer.valueOf(i2), 43612, Integer.valueOf(i3));
            if (a2 == null && (a2 = com.tencent.smtt.utils.q.a(r, "isX5Disabled", new Class[]{Integer.TYPE, Integer.TYPE}, Integer.valueOf(i2), 43612)) == null) {
                return true;
            }
            return ((Boolean) a2).booleanValue();
        } else {
            return true;
        }
    }

    private static boolean a(Context context, boolean z2) {
        int i2;
        File file;
        TbsCoreLoadStat tbsCoreLoadStat;
        int i3;
        Exception exc;
        TbsLog.initIfNeed(context);
        if (!sIsVersionPrinted) {
            TbsLog.i("QbSdk", "svn revision: jnizz; SDK_VERSION_CODE: 43612; SDK_VERSION_NAME: 3.6.0.1310");
            sIsVersionPrinted = true;
        }
        if (a && !z2) {
            TbsLog.e("QbSdk", "QbSdk init: " + v, false);
            TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_SDKINIT_IS_SYS_FORCED, new Throwable(v));
            return false;
        } else if (b) {
            TbsLog.e("QbSdk", "QbSdk init mIsSysWebViewForcedByOuter = true", true);
            TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_FORCE_SYSTEM_WEBVIEW_OUTER, new Throwable(u));
            return false;
        } else {
            if (!B) {
                d(context);
            }
            try {
                File r2 = am.a().r(context);
                if (r2 == null) {
                    TbsLog.e("QbSdk", "QbSdk init (false) optDir == null");
                    TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.ERROR_TBSCORE_SHARE_DIR, new Throwable("QbSdk.init (false) TbsCoreShareDir is null"));
                    return false;
                }
                if (TbsShareManager.isThirdPartyApp(context)) {
                    int i4 = o;
                    if (i4 != 0 && i4 != TbsShareManager.d(context)) {
                        q = null;
                        r = null;
                        TbsLog.e("QbSdk", "QbSdk init (false) ERROR_UNMATCH_TBSCORE_VER_THIRDPARTY!");
                        TbsCoreLoadStat tbsCoreLoadStat2 = TbsCoreLoadStat.getInstance();
                        tbsCoreLoadStat2.a(context, 302, new Throwable("sTbsVersion: " + o + "; AvailableTbsCoreVersion: " + TbsShareManager.d(context)));
                        return false;
                    }
                    i2 = TbsShareManager.d(context);
                } else if (o != 0) {
                    i2 = am.a().a(true, context);
                    if (o != i2) {
                        q = null;
                        r = null;
                        TbsLog.e("QbSdk", "QbSdk init (false) not isThirdPartyApp tbsCoreInstalledVer=" + i2, true);
                        TbsLog.e("QbSdk", "QbSdk init (false) not isThirdPartyApp sTbsVersion=" + o, true);
                        TbsCoreLoadStat tbsCoreLoadStat3 = TbsCoreLoadStat.getInstance();
                        tbsCoreLoadStat3.a(context, TbsListener.ErrorCode.ERROR_UNMATCH_TBSCORE_VER, new Throwable("sTbsVersion: " + o + "; tbsCoreInstalledVer: " + i2));
                        return false;
                    }
                } else {
                    i2 = 0;
                }
                o = i2;
                if (q != null) {
                    return true;
                }
                if (!TbsShareManager.isThirdPartyApp(context)) {
                    file = new File(am.a().r(context), "tbs_sdk_extension_dex.jar");
                } else if (!TbsShareManager.j(context)) {
                    TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.ERROR_HOST_UNAVAILABLE, new Throwable("isShareTbsCoreAvailable false!"));
                    return false;
                } else {
                    file = new File(TbsShareManager.c(context), "tbs_sdk_extension_dex.jar");
                }
                if (file.exists()) {
                    String hostCorePathAppDefined = TbsShareManager.getHostCorePathAppDefined() != null ? TbsShareManager.getHostCorePathAppDefined() : r2.getAbsolutePath();
                    TbsLog.i("QbSdk", "QbSdk init optDirExtension #1 is " + hostCorePathAppDefined);
                    TbsLog.i("QbSdk", "new DexLoader #1 dexFile is " + file.getAbsolutePath());
                    q = new DexLoader(file.getParent(), context, new String[]{file.getAbsolutePath()}, hostCorePathAppDefined, null).loadClass("com.tencent.tbs.sdk.extension.TbsSDKExtension");
                    loadTBSSDKExtension(context, file.getParent());
                    com.tencent.smtt.utils.q.a(r, "setClientVersion", new Class[]{Integer.TYPE}, 1);
                    return true;
                }
                TbsLog.e("QbSdk", "QbSdk init (false) tbs_sdk_extension_dex.jar is not exist!");
                int j2 = am.a().j(context);
                if (new File(file.getParentFile(), "tbs_jars_fusion_dex.jar").exists()) {
                    if (j2 > 0) {
                        tbsCoreLoadStat = TbsCoreLoadStat.getInstance();
                        i3 = TbsListener.ErrorCode.INFO_MISS_SDKEXTENSION_JAR_WITH_FUSION_DEX_WITH_CORE;
                        exc = new Exception("tbs_sdk_extension_dex not exist(with fusion dex)!" + j2);
                    } else {
                        tbsCoreLoadStat = TbsCoreLoadStat.getInstance();
                        i3 = TbsListener.ErrorCode.INFO_MISS_SDKEXTENSION_JAR_WITH_FUSION_DEX_WITHOUT_CORE;
                        exc = new Exception("tbs_sdk_extension_dex not exist(with fusion dex)!" + j2);
                    }
                } else if (j2 > 0) {
                    tbsCoreLoadStat = TbsCoreLoadStat.getInstance();
                    i3 = TbsListener.ErrorCode.INFO_INFO_MISS_SDKEXTENSION_JAR_WITHOUT_FUSION_DEX_WITH_CORE;
                    exc = new Exception("tbs_sdk_extension_dex not exist(without fusion dex)!" + j2);
                } else {
                    tbsCoreLoadStat = TbsCoreLoadStat.getInstance();
                    i3 = TbsListener.ErrorCode.INFO_INFO_MISS_SDKEXTENSION_JAR_WITHOUT_FUSION_DEX_WITHOUT_CORE;
                    exc = new Exception("tbs_sdk_extension_dex not exist(without fusion dex)!" + j2);
                }
                tbsCoreLoadStat.a(context, i3, exc);
                return false;
            } catch (Throwable th) {
                TbsLog.e("QbSdk", "QbSdk init Throwable: " + Log.getStackTraceString(th));
                TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.THROWABLE_QBSDK_INIT, th);
                return false;
            }
        }
    }

    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:182:0x012b -> B:253:0x012d). Please submit an issue!!! */
    public static boolean a(Context context, boolean z2, boolean z3) {
        int i2;
        TbsCoreLoadStat tbsCoreLoadStat;
        int i3;
        Throwable th;
        boolean z4 = false;
        if (TbsShareManager.isThirdPartyApp(context) && !TbsShareManager.i(context)) {
            TbsCoreLoadStat.getInstance().a(context, 302);
            return false;
        } else if (!a(context, z2)) {
            TbsLog.e("QbSdk", "QbSdk.init failure!");
            return false;
        } else {
            boolean z5 = true;
            Object a2 = com.tencent.smtt.utils.q.a(r, "canLoadX5Core", new Class[]{Integer.TYPE}, 43612);
            if (a2 == null) {
                Object a3 = com.tencent.smtt.utils.q.a(r, "canLoadX5", new Class[]{Integer.TYPE}, Integer.valueOf(a.a()));
                if (a3 == null) {
                    TbsCoreLoadStat.getInstance().a(context, 308);
                } else if ((a3 instanceof String) && ((String) a3).equalsIgnoreCase("AuthenticationFail")) {
                    return false;
                } else {
                    if (a3 instanceof Boolean) {
                        o = o.e();
                        boolean a4 = a(context, o.e());
                        Boolean bool = (Boolean) a3;
                        if (bool.booleanValue() && !a4) {
                            z4 = true;
                        }
                        if (!z4) {
                            TbsLog.e(TbsListener.tag_load_error, "318");
                            TbsLog.w(TbsListener.tag_load_error, "isX5Disable:" + a4);
                            TbsLog.w(TbsListener.tag_load_error, "(Boolean) ret:" + bool);
                        }
                        return z4;
                    }
                }
            } else if ((a2 instanceof String) && ((String) a2).equalsIgnoreCase("AuthenticationFail")) {
                return false;
            } else {
                if (!(a2 instanceof Bundle)) {
                    TbsCoreLoadStat tbsCoreLoadStat2 = TbsCoreLoadStat.getInstance();
                    tbsCoreLoadStat2.a(context, TbsListener.ErrorCode.ERROR_QBSDK_INIT_ERROR_RET_TYPE_NOT_BUNDLE, new Throwable("" + a2));
                    TbsLog.e(TbsListener.tag_load_error, "ret not instance of bundle");
                    return false;
                }
                Bundle bundle = (Bundle) a2;
                if (bundle.isEmpty()) {
                    TbsCoreLoadStat tbsCoreLoadStat3 = TbsCoreLoadStat.getInstance();
                    tbsCoreLoadStat3.a(context, TbsListener.ErrorCode.ERROR_QBSDK_INIT_ERROR_EMPTY_BUNDLE, new Throwable("" + a2));
                    TbsLog.e(TbsListener.tag_load_error, "empty bundle");
                    return false;
                }
                try {
                    i2 = bundle.getInt(FontsContractCompat.Columns.RESULT_CODE, -1);
                } catch (Exception e2) {
                    TbsLog.e("QbSdk", "bundle.getInt(KEY_RESULT_CODE) error : " + e2.toString());
                    i2 = -1;
                }
                boolean z6 = i2 == 0;
                if (TbsShareManager.isThirdPartyApp(context)) {
                    o.a(TbsShareManager.d(context));
                    String valueOf = String.valueOf(TbsShareManager.d(context));
                    p = valueOf;
                    if (valueOf.length() == 5) {
                        p = "0" + p;
                    }
                    if (p.length() != 6) {
                        p = "";
                    }
                } else {
                    try {
                        if (Build.VERSION.SDK_INT >= 12) {
                            p = bundle.getString("tbs_core_version", "0");
                        } else {
                            String string = bundle.getString("tbs_core_version");
                            p = string;
                            if (string == null) {
                                p = "0";
                            }
                        }
                    } catch (Exception unused) {
                        p = "0";
                    }
                    try {
                        o = Integer.parseInt(p);
                    } catch (NumberFormatException unused2) {
                        o = 0;
                    }
                    o.a(o);
                    int i4 = o;
                    if (i4 == 0) {
                        TbsCoreLoadStat.getInstance().a(context, 307, new Throwable("sTbsVersion is 0"));
                        return false;
                    }
                    if ((i4 <= 0 || i4 > 25442) && i4 != 25472) {
                        z5 = false;
                    }
                    if (z5) {
                        TbsLog.e(TbsDownloader.LOGTAG, "is_obsolete --> delete old core:" + o);
                        com.tencent.smtt.utils.j.b(am.a().r(context));
                        TbsCoreLoadStat tbsCoreLoadStat4 = TbsCoreLoadStat.getInstance();
                        tbsCoreLoadStat4.a(context, 307, new Throwable("is_obsolete --> delete old core:" + o));
                        return false;
                    }
                }
                try {
                    String[] stringArray = bundle.getStringArray("tbs_jarfiles");
                    t = stringArray;
                    if (!(stringArray instanceof String[])) {
                        TbsCoreLoadStat tbsCoreLoadStat5 = TbsCoreLoadStat.getInstance();
                        tbsCoreLoadStat5.a(context, 307, new Throwable("sJarFiles not instanceof String[]: " + t));
                        return false;
                    }
                    try {
                        d = bundle.getString("tbs_librarypath");
                        Object obj = null;
                        if (i2 != 0) {
                            try {
                                obj = com.tencent.smtt.utils.q.a(r, "getErrorCodeForLogReport", new Class[0], new Object[0]);
                            } catch (Exception e3) {
                                e3.printStackTrace();
                            }
                        }
                        if (i2 != -2) {
                            if (i2 != -1) {
                                if (i2 != 0) {
                                    TbsCoreLoadStat tbsCoreLoadStat6 = TbsCoreLoadStat.getInstance();
                                    tbsCoreLoadStat6.a(context, TbsListener.ErrorCode.INFO_INITX5_FALSE_DEFAULT, new Throwable("detail: " + obj + "errcode" + i2));
                                }
                            } else if (obj instanceof Integer) {
                                tbsCoreLoadStat = TbsCoreLoadStat.getInstance();
                                i3 = ((Integer) obj).intValue();
                                th = new Throwable("detail: " + obj);
                            } else {
                                TbsCoreLoadStat tbsCoreLoadStat7 = TbsCoreLoadStat.getInstance();
                                tbsCoreLoadStat7.a(context, 307, new Throwable("detail: " + obj));
                            }
                            z4 = z6;
                        } else if (obj instanceof Integer) {
                            tbsCoreLoadStat = TbsCoreLoadStat.getInstance();
                            i3 = ((Integer) obj).intValue();
                            th = new Throwable("detail: " + obj);
                        } else {
                            tbsCoreLoadStat = TbsCoreLoadStat.getInstance();
                            i3 = TbsListener.ErrorCode.INFO_DISABLE_X5;
                            th = new Throwable("detail: " + obj);
                        }
                        tbsCoreLoadStat.a(context, i3, th);
                        z4 = z6;
                    } catch (Exception unused3) {
                        return false;
                    }
                } catch (Throwable th2) {
                    TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.ERROR_GETSTRINGARRAY_JARFILE, th2);
                    return false;
                }
            }
            if (!z4) {
                TbsLog.e(TbsListener.tag_load_error, "319");
            }
            return z4;
        }
    }

    private static int b(Context context, String str) {
        BufferedInputStream bufferedInputStream;
        File file = new File(context.getDir("tbs", 0), str);
        if (file.exists()) {
            File file2 = new File(file, "tbs.conf");
            if (file2.exists()) {
                BufferedInputStream bufferedInputStream2 = null;
                try {
                    bufferedInputStream = new BufferedInputStream(new FileInputStream(file2));
                } catch (Throwable unused) {
                }
                try {
                    Properties properties = new Properties();
                    properties.load(bufferedInputStream);
                    int parseInt = Integer.parseInt(properties.getProperty("emergent_core"));
                    try {
                        bufferedInputStream.close();
                    } catch (Exception unused2) {
                    }
                    return parseInt;
                } catch (Throwable unused3) {
                    bufferedInputStream2 = bufferedInputStream;
                    if (bufferedInputStream2 != null) {
                        try {
                            bufferedInputStream2.close();
                        } catch (Exception unused4) {
                        }
                    }
                    return 0;
                }
            }
            return 0;
        }
        return 0;
    }

    public static String b() {
        Object invokeStaticMethod;
        bt a2 = bt.a();
        if (a2 == null || !a2.b() || (invokeStaticMethod = a2.c().b().invokeStaticMethod("com.tencent.tbs.tbsshell.WebCoreProxy", "getGUID", new Class[0], new Object[0])) == null || !(invokeStaticMethod instanceof String)) {
            return null;
        }
        return (String) invokeStaticMethod;
    }

    static boolean b(Context context) {
        SharedPreferences sharedPreferences;
        if (context == null) {
            return false;
        }
        try {
            if (context.getApplicationInfo().packageName.contains("com.tencent.portfolio")) {
                TbsLog.i("QbSdk", "clearPluginConfigFile #1");
                String string = TbsDownloadConfig.getInstance(context).mPreferences.getString(TbsDownloadConfig.TbsConfigKey.KEY_APP_VERSIONNAME, null);
                String str = context.getPackageManager().getPackageInfo("com.tencent.portfolio", 0).versionName;
                TbsLog.i("QbSdk", "clearPluginConfigFile oldAppVersionName is " + string + " newAppVersionName is " + str);
                if (string == null || string.contains(str) || (sharedPreferences = context.getSharedPreferences("plugin_setting", 0)) == null) {
                    return true;
                }
                SharedPreferences.Editor edit = sharedPreferences.edit();
                edit.clear();
                edit.commit();
                TbsLog.i("QbSdk", "clearPluginConfigFile done");
                return true;
            }
            return true;
        } catch (Throwable th) {
            TbsLog.i("QbSdk", "clearPluginConfigFile error is " + th.getMessage());
            return false;
        }
    }

    private static boolean c(Context context) {
        File file;
        try {
            if (q != null) {
                return true;
            }
            File r2 = am.a().r(context);
            if (r2 == null) {
                TbsLog.e("QbSdk", "QbSdk initForX5DisableConfig (false) optDir == null");
                return false;
            }
            if (!TbsShareManager.isThirdPartyApp(context)) {
                file = new File(am.a().r(context), "tbs_sdk_extension_dex.jar");
            } else if (!TbsShareManager.j(context)) {
                TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.ERROR_HOST_UNAVAILABLE);
                return false;
            } else {
                file = new File(TbsShareManager.c(context), "tbs_sdk_extension_dex.jar");
            }
            if (!file.exists()) {
                TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_MISS_SDKEXTENSION_JAR_OLD, new Exception("initForX5DisableConfig failure -- tbs_sdk_extension_dex.jar is not exist!"));
                return false;
            }
            String hostCorePathAppDefined = TbsShareManager.getHostCorePathAppDefined() != null ? TbsShareManager.getHostCorePathAppDefined() : r2.getAbsolutePath();
            TbsLog.i("QbSdk", "QbSdk init optDirExtension #3 is " + hostCorePathAppDefined);
            TbsLog.i("QbSdk", "new DexLoader #4 dexFile is " + file.getAbsolutePath());
            q = new DexLoader(file.getParent(), context, new String[]{file.getAbsolutePath()}, hostCorePathAppDefined, null).loadClass("com.tencent.tbs.sdk.extension.TbsSDKExtension");
            loadTBSSDKExtension(context, file.getParent());
            com.tencent.smtt.utils.q.a(r, "setClientVersion", new Class[]{Integer.TYPE}, 1);
            return true;
        } catch (Throwable th) {
            TbsLog.e("QbSdk", "initForX5DisableConfig sys WebView: " + Log.getStackTraceString(th));
            return false;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:25:0x0036  */
    /* JADX WARN: Removed duplicated region for block: B:27:? A[RETURN, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public static boolean canLoadVideo(android.content.Context r5) {
        /*
            java.lang.Object r0 = com.tencent.smtt.sdk.QbSdk.r
            r1 = 1
            java.lang.Class[] r2 = new java.lang.Class[r1]
            java.lang.Class r3 = java.lang.Integer.TYPE
            r4 = 0
            r2[r4] = r3
            java.lang.Object[] r1 = new java.lang.Object[r1]
            java.lang.Integer r3 = java.lang.Integer.valueOf(r4)
            r1[r4] = r3
            java.lang.String r3 = "canLoadVideo"
            java.lang.Object r0 = com.tencent.smtt.utils.q.a(r0, r3, r2, r1)
            if (r0 == 0) goto L2a
            r1 = r0
            java.lang.Boolean r1 = (java.lang.Boolean) r1
            boolean r1 = r1.booleanValue()
            if (r1 != 0) goto L33
            com.tencent.smtt.sdk.TbsCoreLoadStat r1 = com.tencent.smtt.sdk.TbsCoreLoadStat.getInstance()
            r2 = 313(0x139, float:4.39E-43)
            goto L30
        L2a:
            com.tencent.smtt.sdk.TbsCoreLoadStat r1 = com.tencent.smtt.sdk.TbsCoreLoadStat.getInstance()
            r2 = 314(0x13a, float:4.4E-43)
        L30:
            r1.a(r5, r2)
        L33:
            if (r0 != 0) goto L36
            goto L3c
        L36:
            java.lang.Boolean r0 = (java.lang.Boolean) r0
            boolean r4 = r0.booleanValue()
        L3c:
            return r4
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.smtt.sdk.QbSdk.canLoadVideo(android.content.Context):boolean");
    }

    public static boolean canLoadX5(Context context) {
        return a(context, false, false);
    }

    public static boolean canLoadX5FirstTimeThirdApp(Context context) {
        try {
            if (context.getApplicationInfo().packageName.contains("com.moji.mjweather") && Build.VERSION.SDK_INT == 19) {
                return true;
            }
            if (q == null) {
                File r2 = am.a().r(context);
                if (r2 == null) {
                    TbsLog.e("QbSdk", "QbSdk canLoadX5FirstTimeThirdApp (false) optDir == null");
                    return false;
                }
                File file = new File(TbsShareManager.c(context), "tbs_sdk_extension_dex.jar");
                if (!file.exists()) {
                    TbsLog.e("QbSdk", "QbSdk canLoadX5FirstTimeThirdApp (false) dexFile.exists()=false", true);
                    return false;
                }
                String hostCorePathAppDefined = TbsShareManager.getHostCorePathAppDefined() != null ? TbsShareManager.getHostCorePathAppDefined() : r2.getAbsolutePath();
                TbsLog.i("QbSdk", "QbSdk init optDirExtension #2 is " + hostCorePathAppDefined);
                TbsLog.i("QbSdk", "new DexLoader #2 dexFile is " + file.getAbsolutePath());
                q = new DexLoader(file.getParent(), context, new String[]{file.getAbsolutePath()}, hostCorePathAppDefined, null).loadClass("com.tencent.tbs.sdk.extension.TbsSDKExtension");
                if (r == null) {
                    if (TbsShareManager.e(context) == null && TbsShareManager.getHostCorePathAppDefined() == null) {
                        TbsLogReport.a(context.getApplicationContext()).b(TbsListener.ErrorCode.HOST_CONTEXT_IS_NULL, "host context is null!");
                        return false;
                    }
                    loadTBSSDKExtension(context, file.getParent());
                }
            }
            Object a2 = com.tencent.smtt.utils.q.a(r, "canLoadX5CoreForThirdApp", new Class[0], new Object[0]);
            if (a2 == null || !(a2 instanceof Boolean)) {
                return false;
            }
            return ((Boolean) a2).booleanValue();
        } catch (Throwable th) {
            TbsLog.e("QbSdk", "canLoadX5FirstTimeThirdApp sys WebView: " + Log.getStackTraceString(th));
            return false;
        }
    }

    public static void canOpenFile(Context context, String str, ValueCallback<Boolean> valueCallback) {
        new h(context, str, valueCallback).start();
    }

    public static boolean canOpenMimeFileType(Context context, String str) {
        a(context, false);
        return false;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r0v11, types: [java.util.Properties] */
    /* JADX WARN: Type inference failed for: r6v4, types: [java.io.FileInputStream, java.io.InputStream] */
    public static boolean canOpenWebPlus(Context context) {
        BufferedInputStream bufferedInputStream;
        ?? fileInputStream;
        if (w == 0) {
            w = a.a();
        }
        TbsLog.i("QbSdk", "canOpenWebPlus - totalRAM: " + w);
        boolean z2 = false;
        if (Build.VERSION.SDK_INT < 7 || w < x || context == null) {
            return false;
        }
        BufferedInputStream bufferedInputStream2 = null;
        try {
            bufferedInputStream = new BufferedInputStream(new FileInputStream(new File(am.a().r(context), "tbs.conf")));
        } catch (Throwable th) {
            th = th;
        }
        try {
            Properties properties = new Properties();
            properties.load(bufferedInputStream);
            String property = properties.getProperty("android_sdk_max_supported");
            String property2 = properties.getProperty("android_sdk_min_supported");
            int parseInt = Integer.parseInt(property);
            int parseInt2 = Integer.parseInt(property2);
            int parseInt3 = Integer.parseInt(Build.VERSION.SDK);
            if (parseInt3 <= parseInt && parseInt3 >= parseInt2) {
                int parseInt4 = Integer.parseInt(properties.getProperty("tbs_core_version"));
                try {
                    bufferedInputStream.close();
                } catch (Exception unused) {
                }
                try {
                    fileInputStream = new FileInputStream(new File(am.t(context), "tbs_extension.conf"));
                } catch (Throwable unused2) {
                }
                try {
                    ?? properties2 = new Properties();
                    properties2.load(fileInputStream);
                    int parseInt5 = Integer.parseInt(properties2.getProperty("tbs_local_version"));
                    int parseInt6 = Integer.parseInt(properties2.getProperty(TbsDownloadConfig.TbsConfigKey.KEY_APP_VERSIONCODE_FOR_SWITCH));
                    if (parseInt4 != 88888888 && parseInt5 != 88888888 && parseInt4 <= parseInt5 && parseInt4 == parseInt5 && ((parseInt6 <= 0 || parseInt6 == com.tencent.smtt.utils.b.b(context)) && Boolean.parseBoolean(properties2.getProperty("x5_disabled")))) {
                        if (!TbsDownloadConfig.getInstance(context.getApplicationContext()).mPreferences.getBoolean(TbsDownloadConfig.TbsConfigKey.KEY_SWITCH_BACKUPCORE_ENABLE, false)) {
                            z2 = true;
                        }
                    }
                    try {
                        fileInputStream.close();
                    } catch (Exception unused3) {
                        return !z2;
                    }
                } catch (Throwable unused4) {
                    bufferedInputStream2 = fileInputStream;
                    try {
                        TbsLog.i("QbSdk", "canOpenWebPlus - isX5Disabled Exception");
                        if (bufferedInputStream2 != null) {
                            try {
                                bufferedInputStream2.close();
                            } catch (Exception unused5) {
                            }
                        }
                        z2 = true;
                        return !z2;
                    } catch (Throwable th2) {
                        if (bufferedInputStream2 != null) {
                            try {
                                bufferedInputStream2.close();
                            } catch (Exception unused6) {
                            }
                        }
                        throw th2;
                    }
                }
            }
            TbsLog.i("QbSdk", "canOpenWebPlus - sdkVersion: " + parseInt3);
            try {
                bufferedInputStream.close();
            } catch (Exception unused7) {
            }
            return false;
        } catch (Throwable th3) {
            th = th3;
            bufferedInputStream2 = bufferedInputStream;
            try {
                th.printStackTrace();
                TbsLog.i("QbSdk", "canOpenWebPlus - canLoadX5 Exception");
                if (bufferedInputStream2 != null) {
                    try {
                        bufferedInputStream2.close();
                    } catch (Exception unused8) {
                    }
                }
                return false;
            } catch (Throwable th4) {
                if (bufferedInputStream2 != null) {
                    try {
                        bufferedInputStream2.close();
                    } catch (Exception unused9) {
                    }
                }
                throw th4;
            }
        }
    }

    public static boolean canUseVideoFeatrue(Context context, int i2) {
        Object a2 = com.tencent.smtt.utils.q.a(r, "canUseVideoFeatrue", new Class[]{Integer.TYPE}, Integer.valueOf(i2));
        if (a2 == null || !(a2 instanceof Boolean)) {
            return false;
        }
        return ((Boolean) a2).booleanValue();
    }

    public static void clear(Context context) {
    }

    /* JADX WARN: Removed duplicated region for block: B:54:0x0066  */
    /* JADX WARN: Removed duplicated region for block: B:71:0x006c A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public static void clearAllWebViewCache(android.content.Context r6, boolean r7) {
        /*
            java.lang.StringBuilder r0 = new java.lang.StringBuilder
            r0.<init>()
            java.lang.String r1 = "clearAllWebViewCache("
            r0.append(r1)
            r0.append(r6)
            java.lang.String r1 = ", "
            r0.append(r1)
            r0.append(r7)
            java.lang.String r1 = ")"
            r0.append(r1)
            java.lang.String r0 = r0.toString()
            java.lang.String r1 = "QbSdk"
            com.tencent.smtt.utils.TbsLog.i(r1, r0)
            r0 = 1
            r2 = 0
            com.tencent.smtt.sdk.WebView r3 = new com.tencent.smtt.sdk.WebView     // Catch: java.lang.Throwable -> L48
            r3.<init>(r6)     // Catch: java.lang.Throwable -> L48
            com.tencent.smtt.export.external.extension.interfaces.IX5WebViewClientExtension r3 = r3.getWebViewClientExtension()     // Catch: java.lang.Throwable -> L48
            if (r3 == 0) goto L64
            com.tencent.smtt.sdk.bt r2 = com.tencent.smtt.sdk.bt.a()     // Catch: java.lang.Throwable -> L45
            if (r2 == 0) goto L43
            boolean r3 = r2.b()     // Catch: java.lang.Throwable -> L45
            if (r3 == 0) goto L43
            com.tencent.smtt.sdk.bu r2 = r2.c()     // Catch: java.lang.Throwable -> L45
            r2.a(r6, r7)     // Catch: java.lang.Throwable -> L45
        L43:
            r2 = 1
            goto L64
        L45:
            r2 = move-exception
            r3 = 1
            goto L4b
        L48:
            r3 = move-exception
            r2 = r3
            r3 = 0
        L4b:
            java.lang.StringBuilder r4 = new java.lang.StringBuilder
            r4.<init>()
            java.lang.String r5 = "clearAllWebViewCache exception 2 -- "
            r4.append(r5)
            java.lang.String r2 = android.util.Log.getStackTraceString(r2)
            r4.append(r2)
            java.lang.String r2 = r4.toString()
            com.tencent.smtt.utils.TbsLog.e(r1, r2)
            r2 = r3
        L64:
            if (r2 == 0) goto L6c
            java.lang.String r6 = "is_in_x5_mode --> no need to clear system webview!"
            com.tencent.smtt.utils.TbsLog.i(r1, r6)
            return
        L6c:
            android.webkit.WebView r2 = new android.webkit.WebView     // Catch: java.lang.Throwable -> Lb9
            r2.<init>(r6)     // Catch: java.lang.Throwable -> Lb9
            int r3 = android.os.Build.VERSION.SDK_INT     // Catch: java.lang.Throwable -> Lb9
            r4 = 11
            if (r3 < r4) goto L86
            java.lang.String r3 = "searchBoxJavaBridge_"
            r2.removeJavascriptInterface(r3)     // Catch: java.lang.Throwable -> Lb9
            java.lang.String r3 = "accessibility"
            r2.removeJavascriptInterface(r3)     // Catch: java.lang.Throwable -> Lb9
            java.lang.String r3 = "accessibilityTraversal"
            r2.removeJavascriptInterface(r3)     // Catch: java.lang.Throwable -> Lb9
        L86:
            r2.clearCache(r0)     // Catch: java.lang.Throwable -> Lb9
            if (r7 == 0) goto L95
            android.webkit.CookieSyncManager.createInstance(r6)     // Catch: java.lang.Throwable -> Lb9
            android.webkit.CookieManager r7 = android.webkit.CookieManager.getInstance()     // Catch: java.lang.Throwable -> Lb9
            r7.removeAllCookie()     // Catch: java.lang.Throwable -> Lb9
        L95:
            android.webkit.WebViewDatabase r7 = android.webkit.WebViewDatabase.getInstance(r6)     // Catch: java.lang.Throwable -> Lb9
            r7.clearUsernamePassword()     // Catch: java.lang.Throwable -> Lb9
            android.webkit.WebViewDatabase r7 = android.webkit.WebViewDatabase.getInstance(r6)     // Catch: java.lang.Throwable -> Lb9
            r7.clearHttpAuthUsernamePassword()     // Catch: java.lang.Throwable -> Lb9
            android.webkit.WebViewDatabase r6 = android.webkit.WebViewDatabase.getInstance(r6)     // Catch: java.lang.Throwable -> Lb9
            r6.clearFormData()     // Catch: java.lang.Throwable -> Lb9
            android.webkit.WebStorage r6 = android.webkit.WebStorage.getInstance()     // Catch: java.lang.Throwable -> Lb9
            r6.deleteAllData()     // Catch: java.lang.Throwable -> Lb9
            android.webkit.WebIconDatabase r6 = android.webkit.WebIconDatabase.getInstance()     // Catch: java.lang.Throwable -> Lb9
            r6.removeAllIcons()     // Catch: java.lang.Throwable -> Lb9
            goto Ld2
        Lb9:
            r6 = move-exception
            java.lang.StringBuilder r7 = new java.lang.StringBuilder
            r7.<init>()
            java.lang.String r0 = "clearAllWebViewCache exception 1 -- "
            r7.append(r0)
            java.lang.String r6 = android.util.Log.getStackTraceString(r6)
            r7.append(r6)
            java.lang.String r6 = r7.toString()
            com.tencent.smtt.utils.TbsLog.e(r1, r6)
        Ld2:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.smtt.sdk.QbSdk.clearAllWebViewCache(android.content.Context, boolean):void");
    }

    public static void closeFileReader(Context context) {
        bt a2 = bt.a();
        a2.a(context);
        if (a2.b()) {
            a2.c().p();
        }
    }

    public static void continueLoadSo(Context context) {
        if (TbsConfig.APP_WX.equals(getCurrentProcessName(context)) && WebView.mWebViewCreated) {
            com.tencent.smtt.utils.q.a(r, "continueLoadSo", new Class[0], new Object[0]);
        }
    }

    public static boolean createMiniQBShortCut(Context context, String str, String str2, Drawable drawable) {
        bt a2;
        if (context != null && !TbsDownloader.getOverSea(context) && !isMiniQBShortCutExist(context, str, str2) && (a2 = bt.a()) != null && a2.b()) {
            Bitmap bitmap = drawable instanceof BitmapDrawable ? ((BitmapDrawable) drawable).getBitmap() : null;
            DexLoader b2 = a2.c().b();
            TbsLog.e("QbSdk", "qbsdk createMiniQBShortCut");
            Object invokeStaticMethod = b2.invokeStaticMethod("com.tencent.tbs.tbsshell.WebCoreProxy", "createMiniQBShortCut", new Class[]{Context.class, String.class, String.class, Bitmap.class}, context, str, str2, bitmap);
            TbsLog.e("QbSdk", "qbsdk after createMiniQBShortCut ret: " + invokeStaticMethod);
            if (invokeStaticMethod != null) {
                return true;
            }
        }
        return false;
    }

    /* JADX WARN: Removed duplicated region for block: B:119:0x00f6  */
    /* JADX WARN: Removed duplicated region for block: B:137:0x007b A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    private static void d(android.content.Context r11) {
        /*
            Method dump skipped, instructions count: 334
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.smtt.sdk.QbSdk.d(android.content.Context):void");
    }

    public static boolean deleteMiniQBShortCut(Context context, String str, String str2) {
        bt a2;
        return (context == null || TbsDownloader.getOverSea(context) || (a2 = bt.a()) == null || !a2.b() || a2.c().b().invokeStaticMethod("com.tencent.tbs.tbsshell.WebCoreProxy", "deleteMiniQBShortCut", new Class[]{Context.class, String.class, String.class}, context, str, str2) == null) ? false : true;
    }

    public static void disAllowThirdAppDownload() {
        c = false;
    }

    public static void disableAutoCreateX5Webview() {
        j = false;
    }

    public static void fileInfoDetect(Context context, String str, android.webkit.ValueCallback<String> valueCallback) {
        bt a2 = bt.a();
        if (a2 == null || !a2.b()) {
            return;
        }
        try {
            a2.c().b().invokeStaticMethod("com.tencent.tbs.tbsshell.WebCoreProxy", "fileInfoDetect", new Class[]{Context.class, String.class, android.webkit.ValueCallback.class}, context, str, valueCallback);
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    public static void forceSysWebView() {
        b = true;
        u = "SysWebViewForcedByOuter: " + Log.getStackTraceString(new Throwable());
        TbsLog.e("QbSdk", "sys WebView: SysWebViewForcedByOuter");
    }

    public static long getApkFileSize(Context context) {
        if (context != null) {
            return TbsDownloadConfig.getInstance(context.getApplicationContext()).mPreferences.getLong(TbsDownloadConfig.TbsConfigKey.KEY_TBSAPKFILESIZE, 0L);
        }
        return 0L;
    }

    public static String getCurrentProcessName(Context context) {
        int myPid = Process.myPid();
        String str = "";
        for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : ((ActivityManager) context.getApplicationContext().getSystemService("activity")).getRunningAppProcesses()) {
            if (runningAppProcessInfo.pid == myPid) {
                str = runningAppProcessInfo.processName;
            }
        }
        return str;
    }

    public static String[] getDexLoaderFileList(Context context, Context context2, String str) {
        String[] strArr = t;
        if (!(strArr instanceof String[])) {
            Object a2 = com.tencent.smtt.utils.q.a(r, "getJarFiles", new Class[]{Context.class, Context.class, String.class}, context, context2, str);
            boolean z2 = a2 instanceof String[];
            String[] strArr2 = a2;
            if (!z2) {
                strArr2 = new String[]{""};
            }
            return (String[]) strArr2;
        }
        int length = strArr.length;
        String[] strArr3 = new String[length];
        for (int i2 = 0; i2 < length; i2++) {
            strArr3[i2] = str + t[i2];
        }
        return strArr3;
    }

    public static boolean getDownloadWithoutWifi() {
        return E;
    }

    public static boolean getIsSysWebViewForcedByOuter() {
        return b;
    }

    public static boolean getJarFilesAndLibraryPath(Context context) {
        String str;
        Object obj = r;
        if (obj == null) {
            str = "getJarFilesAndLibraryPath sExtensionObj is null";
        } else {
            Bundle bundle = (Bundle) com.tencent.smtt.utils.q.a(obj, "canLoadX5CoreAndNotLoadSo", new Class[]{Integer.TYPE}, 43612);
            if (bundle != null) {
                t = bundle.getStringArray("tbs_jarfiles");
                d = bundle.getString("tbs_librarypath");
                return true;
            }
            str = "getJarFilesAndLibraryPath bundle is null and coreverison is " + am.a().a(true, context);
        }
        TbsLog.i("QbSdk", str);
        return false;
    }

    public static String getMiniQBVersion(Context context) {
        bt a2 = bt.a();
        a2.a(context);
        if (a2 == null || !a2.b()) {
            return null;
        }
        return a2.c().f();
    }

    public static boolean getOnlyDownload() {
        return k;
    }

    public static String getQQBuildNumber() {
        return z;
    }

    public static Map<String, Object> getSettings() {
        return n;
    }

    public static boolean getTBSInstalling() {
        return F;
    }

    public static String getTID() {
        return y;
    }

    public static String getTbsResourcesPath(Context context) {
        return TbsShareManager.g(context);
    }

    public static int getTbsVersion(Context context) {
        if (TbsShareManager.isThirdPartyApp(context)) {
            return TbsShareManager.a(context, false);
        }
        int j2 = am.a().j(context);
        if (j2 == 0 && ai.a(context).c() == 3) {
            reset(context);
        }
        return j2;
    }

    public static int getTbsVersionForCrash(Context context) {
        if (TbsShareManager.isThirdPartyApp(context)) {
            return TbsShareManager.a(context, false);
        }
        int k2 = am.a().k(context);
        if (k2 == 0 && ai.a(context).c() == 3) {
            reset(context);
        }
        return k2;
    }

    public static void initBuglyAsync(boolean z2) {
        i = z2;
    }

    public static void initForinitAndNotLoadSo(Context context) {
        String str;
        if (q == null) {
            File r2 = am.a().r(context);
            if (r2 == null) {
                str = "QbSdk initForinitAndNotLoadSo optDir == null";
            } else {
                File file = new File(r2, "tbs_sdk_extension_dex.jar");
                if (file.exists()) {
                    q = new DexLoader(file.getParent(), context, new String[]{file.getAbsolutePath()}, r2.getAbsolutePath(), null).loadClass("com.tencent.tbs.sdk.extension.TbsSDKExtension");
                    return;
                }
                str = "QbSdk initForinitAndNotLoadSo dexFile.exists()=false";
            }
            Log.e("QbSdk", str);
        }
    }

    public static void initTbsSettings(Map<String, Object> map) {
        Map<String, Object> map2 = n;
        if (map2 == null) {
            n = map;
            return;
        }
        try {
            map2.putAll(map);
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    public static void initX5Environment(Context context, PreInitCallback preInitCallback) {
        if (context == null) {
            return;
        }
        b(context);
        D = new l(context, preInitCallback);
        if (TbsShareManager.isThirdPartyApp(context)) {
            am.a().c(context, true);
        }
        TbsDownloader.needDownload(context, false, false, new m(context, preInitCallback));
    }

    public static boolean installLocalQbApk(Context context, String str, String str2, Bundle bundle) {
        o a2 = o.a(true);
        a2.b(context, false, false);
        if (a2 == null || !a2.c()) {
            return false;
        }
        return a2.b().a(context, str, str2, bundle);
    }

    public static boolean intentDispatch(WebView webView, Intent intent, String str, String str2) {
        String str3;
        if (webView == null) {
            return false;
        }
        if (str.startsWith("mttbrowser://miniqb/ch=icon?")) {
            Context context = webView.getContext();
            int indexOf = str.indexOf("url=");
            str = indexOf > 0 ? str.substring(indexOf + 4) : null;
            HashMap hashMap = new HashMap();
            try {
                str3 = context.getApplicationInfo().packageName;
            } catch (Exception e2) {
                e2.printStackTrace();
                str3 = EnvironmentCompat.MEDIA_UNKNOWN;
            }
            hashMap.put(LOGIN_TYPE_KEY_PARTNER_ID, str3);
            hashMap.put(LOGIN_TYPE_KEY_PARTNER_CALL_POS, "14004");
            if (com.tencent.smtt.sdk.a.d.a(context, "miniqb://home".equals(str) ? "qb://navicard/addCard?cardId=168&cardName=168" : str, hashMap, "QbSdk.startMiniQBToLoadUrl", null) != 0) {
                bt a2 = bt.a();
                if (a2 != null && a2.b() && a2.c().a(context, str, null, str2, null) == 0) {
                    return true;
                }
            }
            return false;
        }
        webView.loadUrl(str);
        return false;
    }

    public static boolean isMiniQBShortCutExist(Context context, String str, String str2) {
        bt a2;
        Object invokeStaticMethod;
        if (context == null || TbsDownloader.getOverSea(context) || (a2 = bt.a()) == null || !a2.b() || (invokeStaticMethod = a2.c().b().invokeStaticMethod("com.tencent.tbs.tbsshell.WebCoreProxy", "isMiniQBShortCutExist", new Class[]{Context.class, String.class}, context, str)) == null) {
            return false;
        }
        return (invokeStaticMethod instanceof Boolean ? (Boolean) invokeStaticMethod : false).booleanValue();
    }

    public static boolean isTbsCoreInited() {
        o a2 = o.a(false);
        return a2 != null && a2.h();
    }

    public static boolean isX5DisabledSync(Context context) {
        if (ai.a(context).c() == 2) {
            return false;
        }
        if (c(context)) {
            Object a2 = com.tencent.smtt.utils.q.a(r, "isX5DisabledSync", new Class[]{Integer.TYPE, Integer.TYPE}, Integer.valueOf(am.a().j(context)), 43612);
            if (a2 != null) {
                return ((Boolean) a2).booleanValue();
            }
            return true;
        }
        return true;
    }

    public static void loadTBSSDKExtension(Context context, String str) {
        Constructor<?> constructor;
        boolean z2;
        Object newInstance;
        if (r != null) {
            return;
        }
        if (q == null) {
            TbsLog.i("QbSdk", "QbSdk loadTBSSDKExtension sExtensionClass is null");
        }
        try {
            constructor = q.getConstructor(Context.class, Context.class, String.class, String.class, String.class);
            z2 = true;
        } catch (Throwable unused) {
            constructor = null;
            z2 = false;
        }
        try {
            if (TbsShareManager.isThirdPartyApp(context)) {
                Context e2 = TbsShareManager.e(context);
                if (e2 == null && TbsShareManager.getHostCorePathAppDefined() == null) {
                    TbsLogReport.a(context.getApplicationContext()).b(TbsListener.ErrorCode.HOST_CONTEXT_IS_NULL, "host context is null!");
                    return;
                }
                newInstance = !z2 ? e2 == null ? q.getConstructor(Context.class, Context.class, String.class).newInstance(context, e2, TbsShareManager.getHostCorePathAppDefined()) : q.getConstructor(Context.class, Context.class).newInstance(context, e2) : constructor.newInstance(context, e2, TbsShareManager.getHostCorePathAppDefined(), str, null);
            } else if (z2) {
                newInstance = constructor.newInstance(context, context, null, str, (!TbsConfig.APP_WX.equals(getCurrentProcessName(context)) || WebView.mWebViewCreated) ? null : "notLoadSo");
            } else {
                newInstance = q.getConstructor(Context.class, Context.class).newInstance(context, context);
            }
            r = newInstance;
        } catch (Throwable unused2) {
        }
    }

    public static synchronized void preInit(Context context) {
        synchronized (QbSdk.class) {
            preInit(context, null);
        }
    }

    public static synchronized void preInit(Context context, PreInitCallback preInitCallback) {
        synchronized (QbSdk.class) {
            TbsLog.initIfNeed(context);
            TbsLog.i("QbSdk", "preInit -- processName: " + getCurrentProcessName(context));
            TbsLog.i("QbSdk", "preInit -- stack: " + Log.getStackTraceString(new Throwable("#")));
            l = a;
            if (!s) {
                k kVar = new k(context, new j(Looper.getMainLooper(), preInitCallback, context));
                kVar.setName("tbs_preinit");
                kVar.setPriority(10);
                kVar.start();
                s = true;
            }
        }
    }

    public static void reset(Context context) {
        reset(context, false);
    }

    /* JADX WARN: Removed duplicated region for block: B:39:0x005b A[Catch: all -> 0x007b, TryCatch #0 {all -> 0x007b, blocks: (B:28:0x0008, B:30:0x000e, B:32:0x0014, B:37:0x002e, B:39:0x005b, B:41:0x0060), top: B:46:0x0008 }] */
    /* JADX WARN: Removed duplicated region for block: B:41:0x0060 A[Catch: all -> 0x007b, TRY_LEAVE, TryCatch #0 {all -> 0x007b, blocks: (B:28:0x0008, B:30:0x000e, B:32:0x0014, B:37:0x002e, B:39:0x005b, B:41:0x0060), top: B:46:0x0008 }] */
    /* JADX WARN: Removed duplicated region for block: B:48:? A[RETURN, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public static void reset(android.content.Context r5, boolean r6) {
        /*
            java.lang.String r0 = "QbSdk"
            java.lang.String r1 = "QbSdk reset!"
            r2 = 1
            com.tencent.smtt.utils.TbsLog.e(r0, r1, r2)
            com.tencent.smtt.sdk.TbsDownloader.stopDownload()     // Catch: java.lang.Throwable -> L7b
            r1 = 0
            if (r6 == 0) goto L2d
            boolean r6 = com.tencent.smtt.sdk.TbsShareManager.isThirdPartyApp(r5)     // Catch: java.lang.Throwable -> L7b
            if (r6 != 0) goto L2d
            com.tencent.smtt.sdk.am r6 = com.tencent.smtt.sdk.am.a()     // Catch: java.lang.Throwable -> L7b
            int r6 = r6.i(r5)     // Catch: java.lang.Throwable -> L7b
            com.tencent.smtt.sdk.am r3 = com.tencent.smtt.sdk.am.a()     // Catch: java.lang.Throwable -> L7b
            int r3 = r3.j(r5)     // Catch: java.lang.Throwable -> L7b
            r4 = 43300(0xa924, float:6.0676E-41)
            if (r6 <= r4) goto L2d
            if (r6 == r3) goto L2d
            r6 = 1
            goto L2e
        L2d:
            r6 = 0
        L2e:
            com.tencent.smtt.sdk.TbsDownloader.b(r5)     // Catch: java.lang.Throwable -> L7b
            java.lang.String r3 = "tbs"
            java.io.File r3 = r5.getDir(r3, r1)     // Catch: java.lang.Throwable -> L7b
            java.lang.String r4 = "core_share_decouple"
            com.tencent.smtt.utils.j.a(r3, r1, r4)     // Catch: java.lang.Throwable -> L7b
            java.lang.String r3 = "delete downloaded apk success"
            com.tencent.smtt.utils.TbsLog.i(r0, r3, r2)     // Catch: java.lang.Throwable -> L7b
            java.lang.ThreadLocal<java.lang.Integer> r2 = com.tencent.smtt.sdk.am.a     // Catch: java.lang.Throwable -> L7b
            java.lang.Integer r1 = java.lang.Integer.valueOf(r1)     // Catch: java.lang.Throwable -> L7b
            r2.set(r1)     // Catch: java.lang.Throwable -> L7b
            java.io.File r1 = new java.io.File     // Catch: java.lang.Throwable -> L7b
            java.io.File r2 = r5.getFilesDir()     // Catch: java.lang.Throwable -> L7b
            java.lang.String r3 = "bugly_switch.txt"
            r1.<init>(r2, r3)     // Catch: java.lang.Throwable -> L7b
            boolean r2 = r1.exists()     // Catch: java.lang.Throwable -> L7b
            if (r2 == 0) goto L5e
            r1.delete()     // Catch: java.lang.Throwable -> L7b
        L5e:
            if (r6 == 0) goto L94
            com.tencent.smtt.sdk.am r6 = com.tencent.smtt.sdk.am.a()     // Catch: java.lang.Throwable -> L7b
            java.io.File r6 = r6.q(r5)     // Catch: java.lang.Throwable -> L7b
            com.tencent.smtt.sdk.am r1 = com.tencent.smtt.sdk.am.a()     // Catch: java.lang.Throwable -> L7b
            java.io.File r1 = r1.u(r5)     // Catch: java.lang.Throwable -> L7b
            com.tencent.smtt.utils.j.b(r6, r1)     // Catch: java.lang.Throwable -> L7b
            com.tencent.smtt.sdk.am r6 = com.tencent.smtt.sdk.am.a()     // Catch: java.lang.Throwable -> L7b
            r6.b(r5)     // Catch: java.lang.Throwable -> L7b
            goto L94
        L7b:
            r5 = move-exception
            java.lang.StringBuilder r6 = new java.lang.StringBuilder
            r6.<init>()
            java.lang.String r1 = "QbSdk reset exception:"
            r6.append(r1)
            java.lang.String r5 = android.util.Log.getStackTraceString(r5)
            r6.append(r5)
            java.lang.String r5 = r6.toString()
            com.tencent.smtt.utils.TbsLog.e(r0, r5)
        L94:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.smtt.sdk.QbSdk.reset(android.content.Context, boolean):void");
    }

    public static void resetDecoupleCore(Context context) {
        TbsLog.e("QbSdk", "QbSdk resetDecoupleCore!", true);
        try {
            com.tencent.smtt.utils.j.b(am.a().q(context));
        } catch (Throwable th) {
            TbsLog.e("QbSdk", "QbSdk resetDecoupleCore exception:" + Log.getStackTraceString(th));
        }
    }

    public static void setCurrentID(String str) {
        if (str != null && str.startsWith(TID_QQNumber_Prefix)) {
            String substring = str.substring(3);
            y = "0000000000000000".substring(substring.length()) + substring;
        }
    }

    public static void setDisableUnpreinitBySwitch(boolean z2) {
        A = z2;
        TbsLog.i("QbSdk", "setDisableUnpreinitBySwitch -- mDisableUnpreinitBySwitch is " + A);
    }

    public static void setDisableUseHostBackupCoreBySwitch(boolean z2) {
        mDisableUseHostBackupCore = z2;
        TbsLog.i("QbSdk", "setDisableUseHostBackupCoreBySwitch -- mDisableUseHostBackupCore is " + mDisableUseHostBackupCore);
    }

    public static void setDownloadWithoutWifi(boolean z2) {
        E = z2;
    }

    public static void setOnlyDownload(boolean z2) {
        k = z2;
    }

    public static void setQQBuildNumber(String str) {
        z = str;
    }

    public static void setTBSInstallingStatus(boolean z2) {
        F = z2;
    }

    public static void setTbsListener(TbsListener tbsListener) {
        C = tbsListener;
    }

    public static void setTbsLogClient(TbsLogClient tbsLogClient) {
        TbsLog.setTbsLogClient(tbsLogClient);
    }

    public static int startMiniQBToLoadUrl(Context context, String str, HashMap<String, String> hashMap, android.webkit.ValueCallback<String> valueCallback) {
        TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_CODE_MINIQB_STARTMINIQBTOLOADURL_COUNTS);
        if (context == null) {
            return -100;
        }
        bt a2 = bt.a();
        a2.a(context);
        if (!a2.b()) {
            TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_CODE_MINIQB_STARTMINIQBTOLOADURL_ISNOTX5CORE);
            Log.e("QbSdk", "startMiniQBToLoadUrl  ret = -102");
            return -102;
        } else if (context == null || !context.getApplicationInfo().packageName.equals("com.nd.android.pandahome2") || getTbsVersion(context) >= 25487) {
            int a3 = a2.c().a(context, str, hashMap, null, valueCallback);
            if (a3 == 0) {
                TbsCoreLoadStat.getInstance().a(context, TbsListener.ErrorCode.INFO_CODE_MINIQB_STARTMINIQBTOLOADURL_SUCCESS);
            } else {
                TbsLogReport a4 = TbsLogReport.a(context);
                a4.b(TbsListener.ErrorCode.INFO_CODE_MINIQB_STARTMINIQBTOLOADURL_FAILED, "" + a3);
            }
            Log.e("QbSdk", "startMiniQBToLoadUrl  ret = " + a3);
            return a3;
        } else {
            return -101;
        }
    }

    public static boolean startQBForDoc(Context context, String str, int i2, int i3, String str2, Bundle bundle) {
        HashMap hashMap = new HashMap();
        hashMap.put(LOGIN_TYPE_KEY_PARTNER_ID, context.getApplicationContext().getApplicationInfo().processName);
        hashMap.put(LOGIN_TYPE_KEY_PARTNER_CALL_POS, Integer.toString(i2));
        return com.tencent.smtt.sdk.a.d.a(context, str, i3, str2, hashMap, bundle);
    }

    public static boolean startQBForVideo(Context context, String str, int i2) {
        HashMap hashMap = new HashMap();
        hashMap.put(LOGIN_TYPE_KEY_PARTNER_ID, context.getApplicationInfo().processName);
        hashMap.put(LOGIN_TYPE_KEY_PARTNER_CALL_POS, Integer.toString(i2));
        return com.tencent.smtt.sdk.a.d.a(context, str, hashMap);
    }

    public static boolean startQBToLoadurl(Context context, String str, int i2, WebView webView) {
        bt a2;
        Object invokeStaticMethod;
        IX5WebViewBase iX5WebViewBase;
        HashMap hashMap = new HashMap();
        hashMap.put(LOGIN_TYPE_KEY_PARTNER_ID, context.getApplicationInfo().processName);
        hashMap.put(LOGIN_TYPE_KEY_PARTNER_CALL_POS, Integer.toString(i2));
        if (webView == null) {
            try {
                String str2 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).packageName;
                if ((str2 == TbsConfig.APP_WX || str2 == TbsConfig.APP_QQ) && (a2 = bt.a()) != null && a2.b() && (invokeStaticMethod = a2.c().b().invokeStaticMethod("com.tencent.smtt.webkit.WebViewList", "getCurrentMainWebviewJustForQQandWechat", new Class[0], new Object[0])) != null && (iX5WebViewBase = (IX5WebViewBase) invokeStaticMethod) != null) {
                    webView = (WebView) iX5WebViewBase.getView().getParent();
                }
            } catch (Exception unused) {
            }
        }
        return com.tencent.smtt.sdk.a.d.a(context, str, hashMap, "QbSdk.startQBToLoadurl", webView) == 0;
    }

    public static boolean startQbOrMiniQBToLoadUrl(Context context, String str, HashMap<String, String> hashMap, ValueCallback<String> valueCallback) {
        if (context == null) {
            return false;
        }
        bt a2 = bt.a();
        a2.a(context);
        if (hashMap != null && "5".equals(hashMap.get(LOGIN_TYPE_KEY_PARTNER_CALL_POS)) && a2.b()) {
            Bundle bundle = (Bundle) a2.c().b().invokeStaticMethod("com.tencent.tbs.tbsshell.WebCoreProxy", "getAdWebViewInfoFromX5Core", new Class[0], new Object[0]);
        }
        if (com.tencent.smtt.sdk.a.d.a(context, str, hashMap, "QbSdk.startMiniQBToLoadUrl", null) != 0) {
            return a2.b() && (context == null || !context.getApplicationInfo().packageName.equals("com.nd.android.pandahome2") || getTbsVersion(context) >= 25487) && a2.c().a(context, str, hashMap, null, valueCallback) == 0;
        }
        return true;
    }

    public static void unForceSysWebView() {
        b = false;
        TbsLog.e("QbSdk", "sys WebView: unForceSysWebView called");
    }

    public static synchronized boolean unPreInit(Context context) {
        synchronized (QbSdk.class) {
            TbsLog.i("QbSdk", "unPreInit -- begin");
            if (!TbsConfig.APP_WX.equals(getCurrentProcessName(context)) || A || WebView.mWebViewCreated || !(b(context, "core_unzip_tmp") == 1 || b(context, "core_copy_tmp") == 1)) {
                TbsLog.i("QbSdk", "unPreInit -- return false");
                return false;
            }
            TbsLog.i("QbSdk", "unPreInit -- do");
            q = null;
            r = null;
            o.a(true).a();
            am.a().g(context);
            bt.a().c(context);
            s = false;
            TbsLog.i("QbSdk", "unPreInit -- return true");
            return true;
        }
    }

    public static boolean useSoftWare() {
        Object obj = r;
        if (obj == null) {
            return false;
        }
        Object a2 = com.tencent.smtt.utils.q.a(obj, "useSoftWare", new Class[0], new Object[0]);
        if (a2 == null) {
            a2 = com.tencent.smtt.utils.q.a(r, "useSoftWare", new Class[]{Integer.TYPE}, Integer.valueOf(a.a()));
        }
        if (a2 == null) {
            return false;
        }
        return ((Boolean) a2).booleanValue();
    }
}
